﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XianQingHuiBao.aspx.cs" Inherits="Catering.Catering_Page.richang.XianQingHuiBao" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>培训应急</title>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Scripts/zhezhao.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="../../Scripts/My97DatePicker/WdatePicker.js"></script>
    <link href="../../Style/center.css" rel="stylesheet" type="text/css" />
    <link href="../../Style/sysData.css" rel="stylesheet" type="text/css" />
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {
            $("#txt_guanbishijian").focus(function () { WdatePicker({ dateFmt: 'yyyy-MM-dd' }) });
            $("#txt_fashengshijian").focus(function () { WdatePicker({ dateFmt: 'yyyy-MM-dd' }) });
            $("input[name='rbm']").change(function () {
                var _thisval = $(this).val();
                if (_thisval == "是") {
                    $("#tr_xqhb").show("normal");
                } else if (_thisval == "否") {
                    $("#tr_xqhb").hide("normal");
                }
            });
        });

        //添加数据
        function btn_Add() {
            var txt_mingcheng = $("#txt_mingcheng").val();
            var ddl_leibie = $("#ddl_leibie").val();
            var txt_fuzeren = $("#txt_fuzeren").val();
            var txt_fashengshijian = $("#txt_fashengshijian").val();
            var txt_guanbishijian = $("#txt_guanbishijian").val();
            var txt_zhenggaicuoshi = $("#txt_zhenggaicuoshi").val();
            $.ajax({
                type: "Post",
                url: "XianQingHuiBao.aspx/Add",
                data: "{'txt_mingcheng':'" + txt_mingcheng + "','ddl_leibie':'" + ddl_leibie + "','txt_fuzeren':'" + txt_fuzeren + "' , 'txt_fashengshijian':'" + txt_fashengshijian + "' , 'txt_guanbishijian':'" + txt_guanbishijian + "','txt_zhenggaicuoshi':'" + txt_zhenggaicuoshi + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "ok") {
                        alert("保存成功！");
                        window.location.href = 'XianQingHuiBao.aspx';
                    }
                }
            });
        }
        //获取数据
        function btn_Get(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "XianQingHuiBao.aspx/Get",
                data: "{'_id':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_fashengshijian").val(data.d[0] == null ? "" : data.d[0]);
                    $("#txt_fuzeren").val(data.d[1] == null ? "" : data.d[1]);
                    $("#txt_guanbishijian").val(data.d[2] == null ? "" : data.d[2]);
                    $("#ddl_leibie").val(data.d[3] == null ? "" : data.d[3]);
                    $("#txt_mingcheng").val(data.d[4] == null ? "" : data.d[4]);
                    $("#txt_zhenggaicuoshi").val(data.d[5] == null ? "" : data.d[5]);
                    $("#btn_Edit").show();
                    $("#btn_Add").hide();
                    divshow("xqsj_div", "bg");
                }
            });
        }
        //编辑数据
        function btn_Edit() {
            var txt_mingcheng = $("#txt_mingcheng").val();
            var ddl_leibie = $("#ddl_leibie").val();
            var txt_fuzeren = $("#txt_fuzeren").val();
            var txt_fashengshijian = $("#txt_fashengshijian").val();
            var txt_guanbishijian = $("#txt_guanbishijian").val();
            var txt_zhenggaicuoshi = $("#txt_zhenggaicuoshi").val();
            var cid = $("#HidID").val();

            $.ajax({
                type: "Post",
                url: "XianQingHuiBao.aspx/Edit",
                data: "{'_id':'" + cid + "','txt_mingcheng':'" + txt_mingcheng + "','ddl_leibie':'" + ddl_leibie + "','txt_fuzeren':'" + txt_fuzeren + "' , 'txt_fashengshijian':'" + txt_fashengshijian + "' , 'txt_guanbishijian':'" + txt_guanbishijian + "' , 'txt_zhenggaicuoshi':'" + txt_zhenggaicuoshi + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = 'XianQingHuiBao.aspx';
                    }
                }
            });
        }
    </script>
</head>
<body>
    <input type="hidden" id="HidID" />
    <form id="Form1" runat="server">
        <table width="500">
            <tr>
                <td>险情汇报：
                    <input type="radio" name="rbm" value="是" checked="checked" />是
	                <input type="radio" name="rbm" value="否" />否
                </td>
                <td>
                    <input type="button" onclick="$('#btn_Edit').hide(); divshow('xqsj_div', 'bg')" class="input_btn_a" value="新增" />
                </td>
            </tr>
            <tr id="tr_xqhb">
                <td align="center" colspan="2">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0">
                        <thead>
                            <tr>
                                <th>序号
                                </th>
                                <th>名称
                                </th>
                                <th>类别
                                </th>
                                <th>负责人
                                </th>
                                <th>发生时间
                                </th>
                                <th>关闭时间
                                </th>
                                <th>操作
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <asp:Repeater ID="rpt_xiaoqinghuibao" runat="server" OnItemCommand="rpt_xiaoqinghuibao_ItemCommand">
                                <ItemTemplate>
                                    <tr>
                                        <td>
                                            <%#Eval("id")%>
                                        </td>
                                        <td>
                                            <%#Eval("mingcheng")%>
                                        </td>
                                        <td>
                                            <%#Eval("leibie")%>
                                        </td>
                                        <td>
                                            <%#Eval("fuzeren")%>
                                        </td>
                                        <td><%#Eval("fashengshijian","{0:yyyy-MM-dd}")%></td>
                                        <td><%#Eval("guanbishijian","{0:yyyy-MM-dd}")%></td>
                                        <td align="center">
                                            <img alt="" src="../../Images/file.gif" onclick="btn_Get('<%#Eval("id")%>')" style="cursor: pointer;" />
                                            <asp:ImageButton ID="img_btn" runat="server" ImageUrl="../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                                CommandArgument='<%#Eval("id")%>' CommandName="del" />
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </tbody>
                    </table>
                </td>
            </tr>
        </table>
    </form>
    <!--弹出层背景-->
    <div id="bg" class="bg">
    </div>
    <!--弹出层应急情况-->
    <div id="xqsj_div" class="center_div" style="width: 400px; height: 300px; padding: 0px; margin-top: -100px;">
        <div class="div_0207" style="width: 398px; height: 100%; margin: 0px;">
            <h1>
                <img alt="险情事件" src="../../Images/cp_h1_03.gif" />添加险情事件</h1>
            <table width="100%" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="65" height="40" align="right">名称：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_mingcheng" class="input_bg" />
                    </td>
                </tr>
                <tr>
                    <td align="right">类别：
                    </td>
                    <td>
                        <select id="ddl_leibie">
                            <option value="交通">交通</option>
                            <option value="火灾">火灾</option>
                            <option value="刀伤">刀伤</option>
                            <option value="划伤">划伤</option>
                            <option value="烫伤">烫伤</option>
                            <option value="机械伤">机械伤</option>
                            <option value="其他">其他</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td width="65" height="40" align="right">负责人：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_fuzeren" class="input_bg" />
                    </td>
                </tr>
                <tr>
                    <td width="65" height="40" align="right">险情整改措施：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_zhenggaicuoshi" class="input_bg" />
                    </td>
                </tr>
                <tr>
                    <td width="65" height="40" align="right">发生时间：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_fashengshijian" class="input_bg" />
                    </td>
                </tr>
                <tr>
                    <td width="65" height="40" align="right">关闭时间：
                    </td>
                    <td width="110">
                        <input type="text" id="txt_guanbishijian" class="input_bg" />
                    </td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td height="30" align="right">
                        <input type="button" id="btn_Add" onclick="btn_Add()" class="input_btn_a" value="提交" />
                        <input type="button" id="btn_Edit" onclick="btn_Edit()" class="input_btn_a" value="提交" />
                    </td>
                    <td>
                        <input type="button" id="but_Close" onclick='divhidel("xqsj_div", "bg")' class="input_btn_a"
                            value="关闭" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <!--弹出层应急情况   结束-->

</body>
</html>
